﻿
#include "DeviceDemoClock.h"
#include "../PublicService/SettingData.h"
#include <QDateTime>
#include <QDebug>

using namespace DeviceLayer;

DYNAMIC_CREATE(DeviceDemoClock)

DeviceDemoClock::DeviceDemoClock()
{
}

bool DeviceDemoClock::InitFromSettingData(const QString& path)
{
    //必须要调用父类的InitFromSettingData
    bool result = Device::InitFromSettingData(path);
    if (result)
    {
        format = SettingData::instance.GetDataString(path + "/Format");
        if (format.isEmpty())
            format = "yyyy-MM-dd hh:mm:ss";
    }

    return result;
}

bool DeviceDemoClock::QueryData()
{
    QString value = QDateTime::currentDateTime().toString(format);
    PutDataToPool("datetime", value);
    qDebug() << "DeviceDemoClock::QueryData called. name = " << name << " value = " << value;
    return true;
}
